﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ControlPoint.ControlAPI
{
    public class ZWaveMotion : ZWaveDevice, IAction {


        public ZWaveMotion(ZWaveController controller, SettingsList settings)
            : base(controller, settings) {

            ((ZWaveApi.Net.CommandClasses.Basic)this._commandClass).Changed += new EventHandler<ZWaveApi.Net.CommandClasses.Events.MultiLevelChangedEventArgs>(OnChange);
        }

        private void OnChange(object sender, ZWaveApi.Net.CommandClasses.Events.MultiLevelChangedEventArgs e) {
            if (e.Level > 0) {
                if (MotionDetected != null) {
                    MotionDetected(this, "MotionDetected", new ActionValue());
                }
            }
        }

        public void RegisterAction(ActionFiredDelegate actionProcessor) {
            MotionDetected += actionProcessor;
        }

        public event ActionFiredDelegate MotionDetected;
    }
}
